package com.ruoyi.business.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.business.domain.dto.admin.user.TbUserAddressPageQueryDTO;
import com.ruoyi.business.domain.koc.TbUserAddress;
import com.ruoyi.business.service.koc.ITbUserAddressService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * 用户收货地址Controller
 *
 * @author ruoyi
 * @date 2025-09-25
 */
@Validated
@Api(value = "用户收货地址控制器", tags = {"用户收货地址管理"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/user/address")
public class TbUserAddressController extends BaseController {

    private final ITbUserAddressService iTbUserAddressService;

    /**
     * 查询用户收货地址列表
     */
    @ApiOperation("查询用户收货地址列表")
    @SaCheckPermission("business:userAddress:list")
    @GetMapping("/list")
    public TableDataInfo<TbUserAddress> list(TbUserAddressPageQueryDTO dto, PageQuery pageQuery) {
        return iTbUserAddressService.queryPageList(dto, pageQuery);
    }

    /**
     * 获取用户收货地址详细信息
     */
    @ApiOperation("获取用户收货地址详细信息")
    @SaCheckPermission("business:userAddress:query")
    @GetMapping("/{id}")
    public R<TbUserAddress> getInfo(@ApiParam("主键")
                                    @NotNull(message = "主键不能为空")
                                    @PathVariable("id") String id) {
        return R.ok(iTbUserAddressService.getById(id));
    }


}
